1 Introduction
If you’re anything like me, when you first thought of creating your own custom functions in R it felt so wildly out of your comfort zone that you decided against it. They seemed big and scary, and only something the “really good” R coders did. The reality is far from that, and I hope this post does something to dissuade the fear and push you to start creating your own functions. Below, I’d like to discuss the essentials:
- What are functions really?
- Why you should consider making custom functions.
- How you can make your own functions.
- some compelling reasons for functions.
Want to see a function in action? I’ve already written an entire blog post about a function I use almost every day! Check it out here, it is all about cleaning and organizing dataframes.
2 Functionable Functions
Lets cut to chase, straight up what is a function? A function is just more code. You see the function mean(), that’s just more code, the function mutate()? - more code, SuperAwesomeCustomFunctionXXY()? - just more code.